<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--sessionStorage 是关闭这个网站 里面存储的数据就没有了 -->
<button onclick="demo1()">将信息存入sessionStorage</button>
<button onclick="demo2()">sessionStorage读取数据</button>
<button onclick="demo3()">删除sessionStorage</button>
<button onclick="demo4()">清除sessionStorage</button>
<script type="text/javascript">
    const p={name:'老刘',age:18}
    function demo1(){
        sessionStorage.setItem('message',JSON.stringify(p))
        sessionStorage.setItem('somedata','英语')
    }
    function demo2(){
        const x=sessionStorage.getItem('message')
        console.log(JSON.parse(x))

    }
    function demo3(){
        sessionStorage.removeItem('message')
    }
    function demo4(){
        sessionStorage.clear()
    }
</script>
</body>
</html>